//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "PatternsCathFASTAProfile.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String* filenamePatternsCompact        = NULL;
  String* filenameCathFASTAProfile       = NULL;
  String* filenameLigandCathFASTAProfile = NULL;
  String* filenameOut                    = NULL;
  String* nameRelation                   = NULL;
  
  String* typeOfData                     = NULL;
  
  int     positionInPatternFile;
  float   percentagePattern;
  float   percentageFalse;
  
  if (argc < 10) {
    
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./CreateARFFBinaryFileWithCompactPatternFile <Filename In with compact Patterns>";
    cout <<                                             " <Filename CATH FASTA Profile Complete>";
    cout <<                                             " <Filename CATH FASTA Profile Of Sequences in which the Patterns is extracted>";
    cout <<                                             " <Type Of File (Seq, CH, PH, SS, MT)>";
    cout <<                                             " <Position of Patterns in Pattern File (1->20%, 2->40%, 3->60%, 4->80%, 5->90%)>";
    cout <<                                             " <Percentage of patterns to use in the ARFF File>";
    cout <<                                             " <Percentage of false records in the ARFF File>";
    cout <<                                             " <Filename Out - ARFF File (Weka)>";
    cout <<                                             " <Name of Relation in Weka File>";
    cout << endl;
    
    return 0;
    
  }
  else {
    
    filenamePatternsCompact        = new String(argv[1]);
    filenameCathFASTAProfile       = new String(argv[2]);
    filenameLigandCathFASTAProfile = new String(argv[3]);
    
    typeOfData                     = new String(argv[4]);
    
    positionInPatternFile          = atoi(argv[5]);
    percentagePattern              = atof(argv[6]);
    percentageFalse                = atof(argv[7]);

    filenameOut                    = new String(argv[8]);
    nameRelation                   = new String(argv[9]);
    
    
    cout << "----------------------------------------------------------------------------------------------------------------" << endl;
    cout << "                                              Filename In with compact Patterns : " << argv[1] << endl;
    cout << "                                           Filename CATH FASTA Profile Complete : " << argv[2] << endl;
    cout << "    Filename CATH FASTA Profile Of Sequences in which the Patterns is extracted : " << argv[3] << endl;
    cout << "                                             Type Of File (Seq, CH, PH, SS, MT) : " << argv[4] << endl;
    cout << "  Position of Patterns in Pattern File (1->20%, 2->40%, 3->60%, 4->80%, 5->90%) : " << argv[5] << endl;
    cout << "                                 Percentage of patterns to use in the ARFF File : " << argv[6] << endl;
    cout << "                                   Percentage of false records in the ARFF File : " << argv[7] << endl;
    cout << "                                                Filename Out - ARFF File (Weka) : " << argv[8] << endl;
    cout << "                                                  Name of Relation in Weka File : " << argv[9] << endl;
    cout << "----------------------------------------------------------------------------------------------------------------" << endl;
    
  }
  
  PatternsCathFASTAProfile* patternsCathFASTAProfile = new PatternsCathFASTAProfile ();
  
  cout << "Preparing the files..." << endl;
  patternsCathFASTAProfile->FilenamePatternsCompact(filenamePatternsCompact);
  patternsCathFASTAProfile->FilenameOut(filenameOut);
  patternsCathFASTAProfile->PrattPatterns()->NamefileOut(filenameOut);
  
  patternsCathFASTAProfile->FilenameCathFASTAProfile(filenameCathFASTAProfile);
  patternsCathFASTAProfile->FilenameLigandCathFASTAProfile(filenameLigandCathFASTAProfile);
  
  cout << "Loading the data..." << endl;
  if (!patternsCathFASTAProfile->LoadData())
    cout << "Error loading data!" << endl;
  
  cout << "Writing the result in the output file..." << endl;
  if (!patternsCathFASTAProfile->CreateARFFBinary(nameRelation, nameRelation, positionInPatternFile, percentagePattern, percentageFalse, typeOfData))
    cout << "Error creating the ARFF File!" << endl;
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (patternsCathFASTAProfile)       delete patternsCathFASTAProfile;
  
  if (filenamePatternsCompact)        delete filenamePatternsCompact;
  if (filenameCathFASTAProfile)       delete filenameCathFASTAProfile;
  if (filenameLigandCathFASTAProfile) delete filenameLigandCathFASTAProfile;
  if (filenameOut)                    delete filenameOut;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

